<div id="ppNyhedsbrev" style="display:none;">
    <div class="wrap-pp wrap-nyhedsbrev">
        <h4>TILMELD DIG VORES NYHEDSBREV HER OG FÅ</h4>
        <h6>5% rabat på alle onlinekøb!</h6>
        <p>Shop online hele døgnet eller besøg os i butikken på: Ndr. Havnevej 9, 3250 gilleleje </p>
        <div class="QRight">
            <p><label> Mandag &ndash; fredag </label> <span>10.00-17-30</span> </p>
            <p><label>Lørdag</label> <span>10.00-16.00</span> </p>
            <p><label>Søndag</label> <span>11.00-16.00</span> </p>
        </div>
        <div class="QLeft">
            <form id="newsletterForm" method="post" action="<?php echo str_replace('&', '&amp;', $action); ?>">
                <div class="eachRow">
                    <input type="text" id="subscriber_name" name="subscriber_name" class="txtInput" placeholder="Indtast dit navn....."/>
                </div>
                <div class="eachRow">
                    <input type="text" id="subscriber_email" name="subscriber_email" class="txtInput" placeholder="Indtast din e-mail adresse....."/>
                </div>
                <div class="eachRow">
                    <a id="subscriber_button1" href="#" class="btn btnTilmeld">tilmeld</a>
                    <a id="unsubscriber_button1" class="btn btnAfmeld" href="#">Afmeld </a>
                </div>
            </form>
        </div>
    </div>
    <!--wrap-nyhedsbrev-->
</div>
<!--#ppNyhedsbrev-->

<script type="text/javascript">
	var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,6})+$/;
	var post = false;

	$('#subscriber_button1').on('click', function(event){
		event.preventDefault();						
		
		if($('#subscriber_name').val() == ''){
            //showPopup('Navn er ugyldig. Indtast en gyldig navn.');
            $('#subscriber_name').addClass('errorField');

			return false;
		}
		
		if(!mail_filter.test($('#subscriber_email').val())){
            //showPopup('E-mailen er ugyldig. Indtast en gyldig e-mail.');
            $('#subscriber_email').addClass('errorField');

			return false;
		}

        $.ajax({
            type: "POST",
            url: "<?php echo $subscriber_url; ?>",
            data: {'email': $('#subscriber_email').val(), 'name': $('#subscriber_name').val()},
            dataType: "text",
            success: function(data, text, request) {
                showPopup(data);
                post = true;
            } ,
            complete: function(xhr, status) {

            },
            async: false
        });
		
		return false;
	});

    $('#unsubscriber_button1').on('click', function(event){
		event.preventDefault();
		
		if(!mail_filter.test($('#subscriber_email').val())){
            showPopup('E-mailen er ugyldig. Indtast en gyldig e-mail.');

			return false;
		}

        $.ajax({
            type: "POST",
            url: "<?php echo $unsubscriber_url; ?>",
            data: {email: jQuery('#subscriber_email').val()},
            dataType: "text",
            success: function(data, text, request) {
                showPopup(data);
                post = true;
            } ,
            complete: function(xhr, status) {
            },
            async: false
        });
		
		return false;  
	});
	
	jQuery('#TB_closeWindowButton').on('click', function(event){
		jQuery('#subscriber_email').val('');
		jQuery('#subscriber_name').val('');
	});


    function closePopup(){
		jQuery('#subscriber_email').val('');
		jQuery('#subscriber_name').val('');
		
		//jQuery('#TB_closeWindowButton').trigger('click'); 
    }
</script>